
#include "ltdb.h"
#include "ltmutex.h"
#include "ltthread.h"

void
lt_mutex_create(
    lt_mutex_t*     mutex,
    uint32          level
)
{
    InitializeCriticalSectionAndSpinCount(&mutex->cs, LT_SPIN_COUNT);
    
    mutex->thread_id = thread_self_id();
    mutex->level = level;
}

void
mutex_free(
    lt_mutex_t*    mutex           
)
{
    DeleteCriticalSection(&mutex->cs);
}

void
mutex_enter(
    lt_mutex_t*    mutex            
)
{
    EnterCriticalSection(&mutex->cs);
}

void
mutex_exit(
    lt_mutex_t*    mutex            
)
{
    LeaveCriticalSection(&mutex->cs);
}

